package com.itheima.test1;

import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        /*
        需求：
        机票价格按照淡季旺季、头等舱和经济舱收费，输入机票原价、月份和头等舱或经济舱。
        按照如下规则计算机票价格：旺季（5~10月）头等舱9折，经济舱8.5折，淡季（11月到来年4月）头等舱7折，经济舱6.5折
         */
        //分析：
        //1.键盘录入机票原价、月份和头等舱或经济舱
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入机票原价：");
        int ticket = sc.nextInt();
        System.out.println("请输入月份：");
        int month = sc.nextInt();
        System.out.println("请输入头等舱或经济舱：0代表头等舱，1代表经济舱");
        int seat = sc.nextInt();
        //2.判断月份是否在旺季
        if (month >= 5 && month <= 10) {
            //旺季 //3.判断是头等舱还是经济舱
            ticket = getTicket(seat, ticket, 0.9, 0.85);
        }else if ((month >= 1 && month <= 4) || (month >=11 && month <= 12)) {
            //淡季
            ticket = getTicket(seat, ticket, 0.7, 0.65);
        }else{
            System.out.println("月份输入有误");
        }
        System.out.println("机票价格为：" + ticket);
    }

    public static int getTicket(int seat, int ticket, double x, double x1) {
        if (seat == 0) {
            //头等舱
            ticket = (int) (ticket * x);
        } else if (seat == 1) {
            //经济舱
            ticket = (int) (ticket * x1);
        } else {
            System.out.println("头等舱或经济舱输入有误");
        }
        return ticket;
    }
}
